package com.wenwei.sharebox.activity;

import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.widget.TextView;

import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.wenwei.sharebox.R;
import com.wenwei.sharebox.adapter.MessageAdapter;
import com.wenwei.sharebox.base.BaseActivity;
import com.wenwei.sharebox.bean.MessageListBean;
import com.wenwei.sharebox.net.ApiManager;
import com.wenwei.sharebox.net.BaseSubscriber;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/07/09 0009.
 */
public class MessageBoxActivity extends BaseActivity {
    @Bind(R.id.base_title)
    TextView baseTitle;
    @Bind(R.id.recycler)
    XRecyclerView recycler;
    private MessageAdapter mAdapter;
    @Override
    public int setLayoutResourceId() {
        return R.layout.activity_message_box;
    }

    @Override
    protected void initView() {
        super.initView();
        baseTitle.setText("消息盒子");
        recycler.setLayoutManager(new LinearLayoutManager(mContext));
        mAdapter = new MessageAdapter();
        recycler.setAdapter(mAdapter);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.base_back)
    public void onViewClicked() {
        finish();
    }

    @Override
    protected void initData() {
        super.initData();
        getMessageList();
    }

    private BaseSubscriber<ArrayList<MessageListBean>> messageSubscriber;
    private void getMessageList(){
        messageSubscriber = new BaseSubscriber<ArrayList<MessageListBean>>(mContext) {
            @Override
            public void onSuccess(ArrayList<MessageListBean> messageListBeen) {
                mAdapter.setDataList(messageListBeen);
                mAdapter.notifyDataSetChanged();
            }
        };
        ApiManager.getInstance().getMessageList(messageSubscriber);
    }

//    @OnClick({R.id.base_back, R.id.message_box_notify, R.id.message_box_active})
//    public void onClick(View view) {
//        switch (view.getId()) {
//            case R.id.base_back:
//                finish();
//                break;
//            case R.id.message_box_notify:
//                goActivity(mContext,NotifyMessageActivity.class);
//                break;
//            case R.id.message_box_active:
//                break;
//        }
//    }
}
